package JUC;

import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CopyOnWriteArraySet;

public class Unsafe {
    List<Integer> list1 = new Vector<>();
    List<Integer> list2 = Collections.synchronizedList(new ArrayList<>());
    List<Integer> list3 = new CopyOnWriteArrayList<>();

    Set<Integer> set1 =Collections.synchronizedSet(new HashSet<>());
    Set<Integer> set2 =new CopyOnWriteArraySet<>();

    Map<Integer,String> map =new ConcurrentHashMap<>();
    public static void main(String[] args) {
        List<Integer> list = new ArrayList<>();
        for (int i = 0;i<20;i++){
            new Thread(() -> {
                list.add(new Random().nextInt());
                System.out.println(list);
            }).start();
        }
    }
}
